package demo;

import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.Enumeration;

public class FirstServletIncludes extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();
        out.println("<HTML>");
        out.println("<HEAD>");
        out.println("<TITLE>firstServlet</TITLE>");
        out.println("</HEAD>");
        out.println("<BODY>");
        out.println("<B>Original Parameters</B><BR>");
        Enumeration enum1 = request.getAttributeNames();
        while (enum1.hasMoreElements()) {
            String attributeName = (String) enum1.nextElement();
            out.println(attributeName + ": " +
                    request.getAttribute(attributeName) + "<BR>");
        }
        out.println("<B>Included Request Parameters</B><BR>");
        RequestDispatcher rd = request.getRequestDispatcher("/demo2?name=budi");
        rd.include(request, response);
        out.println("</BODY>");
        out.println("</HTML>");
    }
}